package com.ruoyi.OutboundManagement.controller;

import com.ruoyi.OutboundManagement.domain.OtherOutbound;
import com.ruoyi.OutboundManagement.service.IOtherOutboundService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 其他出库管理Controller
 * 
 * @author admin
 * @date 2024-07-04
 */
@RestController
@RequestMapping("/OutboundManagement/otherOutbound")
public class OtherOutboundController extends BaseController
{
    @Autowired
    private IOtherOutboundService otherOutboundService;

    /**
     * 查询其他出库管理列表
     */
    @PreAuthorize("@ss.hasPermi('OutboundManagement:otherOutbound:list')")
    @GetMapping("/list")
    public TableDataInfo list(OtherOutbound otherOutbound)
    {
        startPage();
        List<OtherOutbound> list = otherOutboundService.selectOtherOutboundList(otherOutbound);
        return getDataTable(list);
    }

    /**
     * 导出其他出库管理列表
     */
    @PreAuthorize("@ss.hasPermi('OutboundManagement:otherOutbound:export')")
    @Log(title = "其他出库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OtherOutbound otherOutbound)
    {
        List<OtherOutbound> list = otherOutboundService.selectOtherOutboundList(otherOutbound);
        ExcelUtil<OtherOutbound> util = new ExcelUtil<OtherOutbound>(OtherOutbound.class);
        util.exportExcel(response, list, "其他出库管理数据");
    }

    /**
     * 获取其他出库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('OutboundManagement:otherOutbound:query')")
    @GetMapping(value = "/{otherId}")

    public AjaxResult getInfo(@PathVariable("otherId") Long otherId)
    {
        return success(otherOutboundService.selectOtherOutboundByOtherId(otherId));
    }

    /**
     * 新增其他出库管理
     */
    @PreAuthorize("@ss.hasPermi('OutboundManagement:otherOutbound:add')")
    @Log(title = "其他出库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OtherOutbound otherOutbound)
    {
        return toAjax(otherOutboundService.insertOtherOutbound(otherOutbound));
    }

    /**
     * 修改其他出库管理
     */
    @PreAuthorize("@ss.hasPermi('OutboundManagement:otherOutbound:edit')")
    @Log(title = "其他出库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OtherOutbound otherOutbound)
    {
        return toAjax(otherOutboundService.updateOtherOutbound(otherOutbound));
    }

    /**
     * 删除其他出库管理
     */

    @PreAuthorize("@ss.hasPermi('OutboundManagement:otherOutbound:remove')")
    @Log(title = "其他出库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{otherIds}")
    public AjaxResult remove(@PathVariable Long[] otherIds)
    {
        return toAjax(otherOutboundService.deleteOtherOutboundByOtherIds(otherIds));
    }
}
